<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>电影推荐</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="icon" href="images/logo2.png" >
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-md8 layui-col-md-offset2">
        <form class="layui-form" id="userForm">
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">用户名:</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_username" name="userId" required autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_psw" class="layui-form-label">密码:</label>
                <div class="layui-input-inline">
                    <input type="password" id="L_psw" name="password" lay-verify="required|pass" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="registerBtn" class="layui-form-label"></label>
                <button class="layui-btn" id="registerBtn" lay-filter="registerBtn" lay-submit="">注册</button>
            </div>
        </form>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery','layer','form'],function(){
        var $=layui.jquery;
        var layer=layui.layer;
        var form=layui.form;

        form.on('submit(registerBtn)', function(){
            $.ajax({
                async: false,
                type:"post",
                url:"http://localhost:8888/register.do",
                data:$("#userForm").serialize(),
                dataType:"json",
                success:function(response){
                    console.log(response);
                    alert(response.status);
                    alert(response.msg);

                    if(response.status == 0){
                        //alert(response.msg);
                        console.log(response);
                        layer.msg(response.msg,{
                            offset: 'auto',
                            area:'150px',
                            time:5000
                        },function(){
                            window.location.href="login.html";
                        });
                        return false;
                    }
                    if(response.status == 1){
                        layer.msg(response.msg,{
                            offset: ['255px', '140px'],
                            area:'200px'
                        });
                    }
                }
            });
        });

    });
</script>
</body>
</html>

